package javase.javase01.exercise01;

import java.util.Arrays;

/**
 * @author: Gan
 * @date 2021/4/14 0014 20:56
 * @description:
 **/
public class Solution {
    public static double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int m = nums1.length;
        int n = nums2.length;
        int[] nums = new int[m + n];

        for (int i = 0; i < m; i++)
            nums[i] = nums1[i];
        for (int i = m; i < m + n; i++)
            nums[i] = nums2[i - m];

        Arrays.sort(nums);
        if (nums.length % 2 == 1) {
            return nums[nums.length / 2 + 1] * 1.0;
        } else {
            float n1 =nums[nums.length / 2-1] + nums[nums.length / 2 ];
            float n2= n1/2;
            return n2 *1.00000;
        }
    }

    public static void main(String[] args) {
        int[] nums1 = {1,2,3,4};
        int[] nums2 = {1,2,3,4};//11223344
        System.out.println(findMedianSortedArrays(nums1, nums2));
    }
}
